<!DOCTYPE html>
<html lang="en" style="height:100%;" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="fragment :: common_header(~{::title},~{::script},~{},~{})">
    <title>管理员登录</title>
    <script>
        $(function () {
           //加载本地用户信息
            var userInfo = localDB.loadLoginUser();
            if(userInfo && userInfo.saveMe){
                $("#username").val(userInfo.username);
                $("#password").val(userInfo.password);
                $("#saveMe").attr("checked",true);
            }else{
                $("#username").val("");
                $("#password").val("");
                $("#saveMe").attr("checked",false);
            }
        });
        function loginOk(result) {
            localDB.saveLoginUser();
            //判断是否保存密码
            _confirm("系统提示",result.message,{
                callback:function (v) {
                    if(v){
                        if(result.result=="success"){
                            sendRedirect("/main/mainPage");
                        }
                    }
                }
            });
        }
    </script>
</head>
<body style="height:100%;overflow:hidden;">
<div class="container bg-warning" style="width:100%;height: 100%;">
    <div class="panel panel-success center-block" style="width:500px;height:300px;position: absolute; top: 40%; left: 50%;transform: translate(-50%, -50%);">
        <div class="panel-heading">
            <h3 class="panel-title">
                用户登录
            </h3>
        </div>
        <div class="panel-body">
            <div class="text-center">
                <form id="loginForm" class="form-horizontal" role="form" th:action="@{/system/login}">
                    <div class="form-group">
                        <label for="username" class="col-sm-3 control-label">用户名</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="username" name="username" placeholder="请输入用户名">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="password" class="col-sm-3 control-label">密码</label>
                        <div class="col-sm-6">
                            <input type="password" class="form-control" id="password" name="password" placeholder="请输入密码">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-6 text-right">
                            <div class="checkbox">
                                <label>
                                    <input type="checkbox" id="saveMe">请记住我
                                </label>
                            </div>
                        </div>
                        <div class="col-sm-6 text-left">
                            <button type="button" class="btn btn-success" onclick="_formPost(this,'',loginOk);">登录</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

</body>
</html>